/**
 ***********************************************************************************************************************
 * Copyright (c) 2021, XIE LI Co.,Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations under the License.
 *
 * @file        main.c
 *
 * @brief       main functions.
 *
 * @revision
 * Date         Author          Notes
 * 2021-09-30   Xie Li      First Version
 ***********************************************************************************************************************
 */
#include <stdio.h>
#include <stdlib.h>
#include <tcp_server.h>
#include <tcp_client.h>
#include <udp_server.h>
#include <udp_client.h>

/**
 ***********************************************************************************************************************
 * @brief           usage
 *
 * @param[in]       none
 *
 * @return          none
 ***********************************************************************************************************************
 */
static void usage(const char *proc)
{
    printf("Usage: %s [type(1-5)]\r\n", proc);
}

/**
 ***********************************************************************************************************************
 * @brief           main
 *
 * @param[in]       none
 *
 * @return          none
 ***********************************************************************************************************************
 */
int main(int argc, char *argv[])
{
    if (argc < 2) {
        usage(argv[0]);
        return -1;
    }

    int type = atoi(argv[1]);
    switch (type) {
    case 1:
        tcp_server_run();
        break;
    
    case 2:
        tcp_client_run();
        break;

    case 3:
        udp_server_run();
        break;

    case 4:
        udp_client_run();
        break;

    case 5:
        tcp_server_select_run();
        break;

    default:
        usage(argv[0]);
        return -1;
        break;
    }

    return 0;
}